Web Server
The last part of the tutorial is the web server. The web server listens for GPS position data from the device and updates a map with the recorded positions.
The server is a simple Python Flask Web Server. It has one endpoint for interacting: /data
. This endpoint will return the data recorded (note that the start index for the requested data has to be sent as an argument) and issuing a POST
to this endpoint will append a recorded position to the data. The data is stored in a JSON file to keep things simple.
The web page will check for new data every 20 seconds.
Running the web server
Since we need to access this server from the AVR-IoT Cellular board, the port (8080) the web server utilizes has to be open. If you want to run the web server from your home network, you have to configure your router to open this port. Another alternative is to utilize Digital Ocean or other cloud providers. With Digital Ocean, you simply have to click Create
-> Droplet
in the main dashboard. Then you have to choose your distribution of choice, for example Ubuntu. The cheapest server configuration with a regular SSD is more than enough for this example.
When you have a configuration with either a cloud provider or self hosting ready, you can download the web server here and unzip it.
To run it, first, do pip install -r requirements.py
to install the Python packages (only needed once) and then do python app.py
. Now the server is ready and you can access the webpage on the second IP address printed from the terminal. Copy the IP address and replaced it with <your server IP here>
in the HTTP_DOMAIN
define in the Arduino Sketch. You only need to copy the IP part, not the port.
You should now see the recorded positions appear on the map 😄